import {WaitDownState} from "../interfaces";
import downningState from "./4Downning";
import weightState from "./2weight";
import state from "./state";
import weighter from "../weight";

class WaitDownStateImpl implements WaitDownState {
    name = "WaitDownState"

    init() {
    }

    leave(): void {
    }

    plate(vehicleNumber: string, inout: string): void {
    }

    active(R: boolean[]): void {
    }

    weight_data(weight: number, wen: boolean): void {
        if (weight < 0.5 || state.wenWeight - weight > 3) {
            state.stateContext = downningState;
            weighter.emit('weight_data', weight, wen)
        }
    }

    driverRequest(type: string): void {
        if (type === 'reWeight') {
            state.stateContext = weightState;
        }
    }

    do_weigh(weight: number, deductionWeight: number): void {
    }

}

const waitDownState = new WaitDownStateImpl();
export default waitDownState;